home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 9.0 KB | 250 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: MemoryMonitorOperations.Lib
- #
- # Contains: Tasks which extend the basic functionality of the MemoryMonitor.vulib.
- #
- # Written by: KTA
- #
- # Copyright: © 1993-1997 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # 1.0.6 02/12/97 JAS Added 'vers' resources to library.
- # These should always match tool version when tool is revved.
- # <9> 2/28/95 ML marked
- # <8> 2/16/95 KTA _MemoryMonitor() - Fixed a couple of bugs
- # <7> 2/10/95 KTA _MemoryMonitor() - Fixed problem where gMemoryMonitorInitFlag
- # was set incorrectly (thrown out).
- # <6> 1/19/95 KTA Changed the name of ExceptionHandler() to ExceptionDispatcher().
- # <5> 1/13/95 KTA _MemoryMonitor() - Added support for calling tasks as well as
- # services.
- # <4> 12/12/94 KTA _MemoryMonitor() - changed match[target] to match[mouse].
- # <3> 12/12/94 KTA Added _MemoryMonitor()
- # <2> 4/29/94 ML Repaced Task with TASK
- # <1> 3/28/94 KTA Created - first checked in.
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "MemoryMonitor.vulib","ExceptionHandling.Lib";
-
- #########################################################################
- # _MemoryMonitor(pServiceOrTask, pParamList, pOnTarget, pIsRetry)
- #========================================================================
- # Author: KTA
- # Description: Does the exception handling for the MemoryMonitor. All high level tasks
- # should call this routine for MemoryMonitor tool services.
- # Handles initialization of tool automatically.
- # Parameters: pServiceOrTask - Name of the Service
- # pParamList - List of parameters
- # pOnTarget - Flag to indicate whether the service should be performed
- # the host or the target. 1 = target/0 = host.
- # Returns: What ever the MemoryMonitor returns - list of three elements
- # { errCode, Data, [error message]}
- # Examples: _MemoryMonitor('GetProcess', {'SystemZone'},1);
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 12/12/94 Created
- # KTA 1/13/95 Added support for calling tasks as well as services
- # KTA 2/10/95 Fixed problem where gMemoryMonitorInitFlag was set incorrectly (thrown out)
- # ML 2/14/95 coerce pOnTarget to be either true or false, Temporarily
- # turn commandexceptions off, check scripterror, reset
- # commandexceptions, and if necessary throw scripterror
- #########################################################################
- TASK _MemoryMonitor(pServiceOrTask, pParamList := {}, pOnTarget := true, pIsRetry := 0)
- begin
- Try
- begin
- returnVal := undefined;
- ParamType := TypeOf(pServiceOrTask);
-
- if (ParamType = 'string') # Service Call
- begin
- if (pOnTarget)
- pOnTarget := true;
- else
- pOnTarget := false;
- if not(global gMemoryMonitorInitFlag = pOnTarget)
- begin
- try
- begin
- temp := CommandExceptions(0);
- MemoryMonitorInit := MemoryMonitor("Initialize", pOnTarget ); # initialize MemoryMonitor
- InitError := Scripterror();
- CommandExceptions(temp);
- if (MemoryMonitorInit[1] <> 0) # If error
- begin
- println "MemoryMonitor error ( ", MemoryMonitorInit[1], ", ", MemoryMonitorInit[3] , " )";
- gMemoryMonitorInitFlag := undefined;
- if (CommandExceptions())
- throw InitError;
- return(MemoryMonitorInit);
- end;
- else
- gMemoryMonitorInitFlag := pOnTarget;
- end;
- catch theErr
- begin
- ExceptionDispatcher(theErr);
- return(MemoryMonitorInit);
- end;
- end;
-
- try
- begin
- NumParams := Card(pParamList);
- switch NumParams
- begin
- case 0: # 0 parameters
- returnVal := MemoryMonitor(pServiceOrTask);
- case 1: # 1 parameter
- returnVal := MemoryMonitor(pServiceOrTask, pParamList[1]);
- case 2: # 2 parameters
- returnVal := MemoryMonitor(pServiceOrTask, pParamList[1], pParamList[2]);
- case 3: # 3 parameters
- returnVal := MemoryMonitor(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]);
- case 4: # 4 parameters
- returnVal := MemoryMonitor(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]);
- case 5: # 5 parameters
- returnVal := MemoryMonitor(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]);
- case 6: # 6 parameters
- returnVal := MemoryMonitor(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]);
- default: # error
- println "Error - unsupported number of parameters - {NumParams}";
- end;
-
- if (returnVal[1] <> 0) # If error
- begin
- if(returnVal[1] = -1) and not (pIsRetry) # Not initialized, and haven't retried already
- begin
- global gMemoryMonitorInitFlag := undefined;
- returnVal := _MemoryMonitor(pServiceOrTask, pParamList, pOnTarget, 1);
- end;
- end;
- else if(pServiceOrTask = 'Quit') # Reset the global gMemoryMonitorInitFlag when we quit
- global gMemoryMonitorInitFlag := undefined;
-
- end;
- catch theErr
- begin
- if(theErr = -1220) and not (pIsRetry)
- begin
- global gMemoryMonitorInitFlag := undefined;
- returnVal := _MemoryMonitor(pServiceOrTask, pParamList, pOnTarget, 1);
- end;
- else
- exceptionDispatcher(theErr);
- end;
- end;
- else if(ParamType = 'task')
- begin
- NumParams := Card(pParamList);
- switch NumParams
- begin
- case 0: # 0 parameters
- returnVal := call (pServiceOrTask);
- case 1: # 1 parameter
- returnVal := call (pServiceOrTask, pParamList[1]);
- case 2: # 2 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2]);
- case 3: # 3 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]);
- case 4: # 4 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]);
- case 5: # 5 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]);
- case 6: # 6 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]);
- default: # error
- println "Error - unsupported number of parameters - {NumParams}";
- end;
- end;
-
- if(pOnTarget) # To cause target errors to throw if Xtools are called
- match[mouse];
-
- return(returnVal);
- end;
- Catch theError
- ExceptionDispatcher(theError);
- end;
-
-
-
- #########################################################################
- # MemoryMonitorInit(pOnTarget)
- #========================================================================
- # Author: KTA
- # Description: Makes a call to initialize MemoryMonitor. Defalut is to
- # initalize it on the Target.
- # Parameters: pOnTarget - True means Memory Monitor will be initialized
- # on the Target.
- # - False means Memory Monitor will be initialized
- # on the Host.
- # Returns: 1 - initialization was successful.
- # 0 - initialization failed
- # Examples: MemoryMonitorInit();
- # Assumptions:
- #========================================================================
- # History:
- # KTA 3/08/94 Created
- # KTA 12/12/94 Added calls to _MemoryMonitor()
- #########################################################################
- TASK MemoryMonitorInit(pOnTarget := True)
- begin
- returnVal := 0;
-
- initResult := _MemoryMonitor('Initialize',{pOnTarget});
- if(initResult[1] <> 0)
- begin
- println "Problem initializing Memory Monitor"; # print error
- println "Error ", initResult[1], ". ", initResult[3] ;
- end;
- else
- begin
- returnVal := 1;
- end;
- return(returnVal);
- end;
-
- #########################################################################
- # MemoryMonitorQuit()
- #========================================================================
- # Author: KTA
- # Description: Makes a call to quit MemoryMonitor.
- # Parameters: none
- # Returns: 1 - quitting was successful.
- # 0 - quitting failed
- # Examples: MemoryMonitorQuit();
- # Assumptions:
- #========================================================================
- # History:
- # KTA 3/08/94 Created
- # KTA 12/12/94 Added calls to _MemoryMonitor()
- #########################################################################
- TASK MemoryMonitorQuit()
- begin
- returnVal := 0;
- QuitResult := _MemoryMonitor('Quit');
- if(QuitResult[1] <> 0)
- begin
- println "Problem quitting Memory Monitor"; # print error
- println "Error ", QuitResult[1], ". ", QuitResult[3] ;
- end;
- else
- begin
- returnVal := 1;
- end;
- return(returnVal);
- end;
-